#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<vector>

using namespace std;

vector<int> searchRange(vector<int>& nums, int target) {
    int n = nums.size();
    if (n == 0)  return { -1,-1 };
    int l = 0, r = n - 1;
    vector<int> res(2);
    while (l < r)
    {
        int mid = l + r >> 1;
        if (nums[mid] >= target) r = mid;
        else l = mid + 1;
    }
    if (nums[l] != target)   return { -1,-1 };
    res[0] = l;
    l = 0, r = n - 1;
    while (l < r)
    {
        int mid = l + r + 1 >> 1;
        if (nums[mid] <=
            target)  l = mid;
        else r = mid - 1;
    }
    res[1] = l;
    return res;
}